package com.cheyun.netsalev3.utils

import android.os.Build
import android.view.View
import android.view.Window


/**
 * Description：控制虚拟栏
 */
object NavigationBarUtil {

    /**
     * 隐藏虚拟栏 ，显示的时候再隐藏掉
     * @param window
     */
    fun hideNavigationBar(window: Window?) {
        window?.decorView?.systemUiVisibility = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
        window?.decorView?.setOnSystemUiVisibilityChangeListener {
            var uiOptions = View.SYSTEM_UI_FLAG_LAYOUT_STABLE or
                    //布局位于状态栏下方
                    View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION or
                    //全屏
//                    View.SYSTEM_UI_FLAG_FULLSCREEN or
                    //隐藏导航栏
                    View.SYSTEM_UI_FLAG_HIDE_NAVIGATION or
                    View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN

            uiOptions = if (Build.VERSION.SDK_INT >= 19) {
                uiOptions or View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
            } else {
                uiOptions or View.SYSTEM_UI_FLAG_LOW_PROFILE
            }
            window.decorView.systemUiVisibility = uiOptions
        }
    }

}
